/* eslint-disable prettier/prettier */
import {NestFactory, Reflector} from '@nestjs/core';
import {AppModule} from './app.module';
import {ClassSerializerInterceptor, Logger, ValidationPipe, VersioningType} from '@nestjs/common';
import {DocumentBuilder, SwaggerModule} from '@nestjs/swagger';

const listenPort = 5000;
const logger = new Logger('main.ts');
const bootstrap = async () => {
    const app = await NestFactory.create(AppModule);

    app.useGlobalPipes(new ValidationPipe());
    app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));

    //setup swagger-ui
    const config = new DocumentBuilder()
        .setTitle('App example')
        .setDescription('The App API description')
        .setVersion('1.0')
        .addTag('App')
        .build();
    const document = SwaggerModule.createDocument(app, config);
    SwaggerModule.setup('swagger-ui', app, document);

    app.enableVersioning({
        type: VersioningType.URI,
    });
    logger.log(`listen in http://localhost:${listenPort}`);
    await app.listen(listenPort);
};
bootstrap();
